import { Router } from 'vue-router'
import setupUserLoginGuard from './guard/userLoginInfo'
import setupPermissionGuard from './guard/permission'

export const createRouterGuard = (router: Router) => {
  setupUserLoginGuard(router)
  setupPermissionGuard(router)
}
export const LOGIN = {
  path: '/login',
  name: 'login',
  component: () => import('@/views/login/index.vue'),
}
// error
export const ERROR_ROUTE = {
  path: '/error/:code',
  name: 'error',
  component: () => import('@/views/error/index.vue'),
}
//默认
export const NOT_FOUND_ROUTE = {
  path: '/:pathMatch(.*)*',
  name: 'notFound',
  redirect: '/error/404',
}
//对外页面
export const EXTERNAL_ROUTE = {
  path: '/external',
  name: '对外',
  component: () => import('@/layout/default-layout.vue'),
  children: [],
}
export const baseRouter = [
  {
    path: '/',
    name: 'index',
    component: () => import('@/layout/default-layout.vue'),
    children: [
      {
        path: '/',
        name: '首页',
        component: () => import('@/views/home/index.vue'),
      },
    ],
  },
  LOGIN,
  ERROR_ROUTE,
  EXTERNAL_ROUTE,
  // NOT_FOUND_ROUTE,
]
